<table width="560" border="0" cellspacing="0" cellpadding="0" style="border-left:1px solid #333;border-right:1px solid #333;border-bottom:1px solid #333">
 
    <?php
  	$query=mysql_query("select DISTINCT quan from khachhangthanthiet where thanhpho='Hồ Chí Minh'");
	while($r=mysql_fetch_array($query))
	{
		$quan=$r["quan"];
	?>
  <tr><td colspan="5" height="5px"></td></tr>
  <tr bgcolor="#FF6633" align="center" height="30" style="font-weight:bold">
  <td colspan="5" align="left" style="padding-left:10px;" height="30"><?php echo "Quận/Huyện: $quan" ?></td>
  </tr>
  <tr bgcolor="#FFCC99" align="center" height="30" style="font-weight:bold">
    <td width="200" style="border-right:1px solid #666">Loại hình
kinh doanh</td>
    <td width="100" style="border-right:1px solid #666">Tên</td>
    <td width="360">Địa chỉ</td>
  </tr>
  <?php
  $sql="select * from khachhangthanthiet where quan='$quan'";
  $kq=mysql_query($sql);
		while($r2=mysql_fetch_array($kq))
		{
			$loaihinhkd=$r2["loaihinhkd"];$ten=$r2["ten"];
			$diachi=$r2["diachi"];			
  ?>	  
  <tr bgcolor="#FFFFCC" align="center" height="30" style="font-weight:bold">
    <td width="200" style="border-right:1px solid #666; border-bottom:1px dotted #000"><?php echo $loaihinhkd; ?><br />
</td>
    <td width="100" style="border-right:1px solid #666; border-bottom:1px dotted #000"><?php echo $ten; ?></td>
    <td width="360" style="border-bottom:1px dotted #000"><?php echo $diachi; ?></td>
  </tr>
  <?php
		}
	}
  ?>  	

<?php
  	$query3=mysql_query("select DISTINCT thanhpho from khachhangthanthiet where thanhpho<>'Hồ Chí Minh'");
	while($r3=mysql_fetch_array($query3))
	{
		$thanhpho3=$r3["thanhpho"];		
?>
    <tr><td colspan="5" height="5px"></td></tr>
      <tr bgcolor="#FF6633" align="center" height="30" style="font-weight:bold">
      <td colspan="5" align="left" style="padding-left:10px;" height="30"><?php echo "Tỉnh/Thành Phố: $thanhpho3" ?></td>
      </tr>
      <tr bgcolor="#FFCC99" align="center" height="30" style="font-weight:bold">
        <td width="200" style="border-right:1px solid #666">Loại hình
    kinh doanh</td>
        <td width="100" style="border-right:1px solid #666">Tên</td>
        <td width="360">Địa chỉ</td>
      </tr>	
	<?php
  $sql4="select * from khachhangthanthiet where thanhpho='$thanhpho3'";
  $kq4=mysql_query($sql4);
		while($r4=mysql_fetch_array($kq4))
		{
			$loaihinhkd4=$r4["loaihinhkd"];$ten4=$r4["ten"];
			$diachi4=$r4["diachi"];			
  ?>	  
  <tr bgcolor="#FFFFCC" align="center" height="30" style="font-weight:bold">
    <td width="200" style="border-right:1px solid #666; border-bottom:1px dotted #000"><?php echo $loaihinhkd4; ?><br />
</td>
    <td width="100" style="border-right:1px solid #666; border-bottom:1px dotted #000"><?php echo $ten4; ?></td>
    <td width="360" style="border-bottom:1px dotted #000"><?php echo $diachi4; ?></td>
  </tr>
  <?php
		}
	}
  ?>  	
</table>